import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 倒入导入全局样式
import './assets/css/global.css'
// 完整引入组件库
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)
Vue.prototype.$message = ElementUI.Message
// 导入字体图标
import './assets/fonts/iconfont.css'
// 导入树形表格
import ZkTable from 'vue-table-with-tree-grid'

Vue.component('tree-table', ZkTable)
// 导入进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// axios请求配置
import axios from 'axios'

// axios拦截器
// 在拦截器中展示进度条
axios.interceptors.request.use(config => {
  NProgress.start()
  // 请求携带token
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 最后必须return
  return config
})

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 此处隐藏进度条
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
Vue.prototype.$http = axios

Vue.config.productionTip = false

// 时间过滤器
Vue.filter('dataFromTime', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y} - ${m} - ${d} ${hh} : ${mm} : ${ss}`
})

// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
